﻿using BCCommon.Enums;
using BCCommon.Enums.Driver;
using BCCommon.TMS.Driver;
using BCEntity.TMS.Driver;
using BCEntity.TMS.KanBan.AgentKanBan;
using BCEntity.Website.User;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BCData.TMS.Driver
{
    public interface IDriverData
    {
        /// <summary>
        /// 创建司机信息
        /// </summary>
        /// <param name="entity">司机信息</param>
        /// <returns></returns>
        Task<DriverEntity> InsertAsync(DriverEntity entity, string passCode = null, string ip = null, string addressIp = null);

        /// <summary>
        /// 获取最大的UserId
        /// </summary>
        /// <returns></returns>
        Task<int> GetMaxUserIdAsync();

        /// <summary>
        /// 检查司机是否已存在
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <returns></returns>
        Task<bool> CheckDriverExistsByPhoneAsync(string phone);

        /// <summary>
        /// 检查司机是否已存在
        /// </summary>
        /// <param name="vehicleNo">车牌号</param>
        /// <returns></returns>
        Task<bool> CheckDriverExistsByVehicleNoAsync(string vehicleNo);
        /// <summary>
        /// 根据身份证号获取司机信息
        /// </summary>
        /// <param name="identityCardNo">身份证号</param>
        /// <returns></returns>
        Task<DriverEntity> GetDriverByIdentityCardNoAsync(string identityCardNo);

        /// <summary>
        /// 获取司机信息列表（分页）
        /// </summary>
        /// <param name="companyId">总公司/代理商Id</param>
        /// <param name="phone">手机</param>
        /// <param name="name">司机名</param>
        /// <param name="vehicleNo">车牌号</param>
        /// <param name="provinceCode">省编码</param>
        /// <param name="cityCode">市编码</param>
        /// <param name="countyCode">区县编码</param>
        /// <param name="driverStatus">审核状态</param>       
        /// <param name="role">司机角色</param>       
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>       
        /// <param name="ascending">是否升序排序</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">每页条数</param>
        Task<(IEnumerable<DriverEntity>, int)> GetDriversAsync(long? companyId, string phone, string name, string vehicleNo, string provinceCode, string cityCode, string countyCode, DriverStatus? driverStatus,DriverRoleType? role, DateTime? start, DateTime? end, bool? ascending, string sortName, int pageIndex, int pageSize);
        /// <summary>
        /// 根据手机号查询司机信息
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <returns></returns>
        Task<DriverEntity> GetDriverByPhoneAsync(string phone);

        /// <summary>
        /// 根据司机Id查询司机信息
        /// </summary>
        /// <param name="driverId">司机Id</param>
        /// <returns></returns>
        Task<DriverEntity> GetDriverByIdAsync(long driverId);
        /// <summary>
        /// 根据用户Id查询司机信息
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        Task<DriverEntity> GetDriverByUserIdAsync(long userId);
        /// <summary>
        /// 根据车牌号获取司机信息
        /// </summary>
        /// <param name="vehicleNo">车牌号</param>
        /// <returns></returns>
        Task<DriverEntity> GetDriverByVehicleNoAsync(string vehicleNo);

        /// <summary>
        /// 根据手机号和密码查询司机信息
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <param name="paswword">密码</param>
        /// <returns></returns>
        Task<DriverEntity> GetDriverByPhoneAndPasswordAsync(string phone, string paswword);

        #region 健康证信息
        /// <summary>
        /// 更新健康证信息
        /// </summary>
        /// <param name="driverEntity">健康证信息</param>
        /// <returns></returns>
        Task<DriverEntity> UpdateHealthCertificateAsync(DriverEntity driverEntity);
        #endregion



        #region 实名认证

        /// <summary>
        /// 实名认证
        /// </summary>
        /// <param name="entity">司机实名信息</param>
        /// <returns></returns>
        Task<DriverEntity> RealNameVerifiesAsync(DriverEntity entity);

        /// <summary>
        /// 实名认证审核
        /// </summary>
        /// <returns></returns>
        Task<DriverEntity> RealNameVerifiesApproveAsync(DriverEntity entity);

        #endregion

        #region 人脸识别认证
        /// <summary>
        /// 人脸识别
        /// </summary>
        /// <param name="entity">人脸识别信息</param>
        /// <returns></returns>
        Task<DriverEntity> FaceVerifiesAsync(DriverEntity entity);

        /// <summary>
        /// 人脸识别认证审核
        /// </summary>
        /// <param name="entity">人脸识别认证审核信息</param>
        /// <returns></returns>
        Task<DriverEntity> FaceVerifiesApproveAsync(DriverEntity entity);
        #endregion

        #region 车辆信息
        /// <summary>
        /// 更新车辆信息
        /// </summary>
        /// <param name="entity">司机信息</param>
        /// <returns></returns>
        Task<DriverEntity> UpdateVehicleAsync(DriverEntity entity);


        /// <summary>
        /// 更新电动车辆信息
        /// </summary>
        /// <param name="entity">司机信息</param>
        /// <returns></returns>
        Task<DriverEntity> UpdateElectricVehicleAsync(DriverEntity entity);

        /// <summary>
        /// 车辆审核
        /// </summary>
        /// <param name="entity">车辆审核信息</param>
        /// <returns></returns>
        Task<DriverEntity> VehicleApproveAsync(DriverEntity entity);
        #endregion


        #region 工作城市
        /// <summary>
        /// 切换城市信息
        /// </summary>
        /// <param name="entity">司机信息</param>
        /// <returns></returns>
        Task<DriverEntity> ChangeCityAsync(DriverEntity entity);

        #endregion

        #region 培训考试
        /// <summary>
        /// 司机培训考试通过
        /// </summary>
        /// <param name="driverId"></param>
        /// <param name=""></param>
        /// <returns></returns>
        Task<DriverEntity> TrainPassedAsync(long driverId);

        /// <summary>
        /// 司机培训考试不通过
        /// </summary>
        /// <param name="driverId"></param>
        /// <param name=""></param>
        /// <returns></returns>

        Task<DriverEntity> TrainUnPassedAsync(long driverId);

        #endregion       

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="driverEntity">司机信息</param>
        /// <returns></returns>
        Task<bool> UpdatePassword(DriverEntity driverEntity);
        /// <summary>
        /// 切换工作状态
        /// </summary>
        /// <param name="entity">司机信息</param>
        /// <returns></returns>
        Task<DriverEntity> ChangeWorkingStatusAsync(DriverEntity entity);
        /// <summary>
        /// 更新图像信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> UpdateAvatarAsync(DriverEntity entity);
        /// <summary>
        /// 更新昵称信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> UpdatePetnameAsync(DriverEntity entity);
        /// <summary>
        /// 安全培训考试通过
        /// </summary>
        /// <param name="driverId">司机id</param>
        /// <returns></returns>
        Task<DriverEntity> LearnTrainPassedAsync(long driverId);

        /// <summary>
        /// 培训签到
        /// </summary>
        /// <param name="driverId"></param>
        /// <param name="isLearnTrainSign">签到</param>
        /// <returns></returns>
        Task<DriverEntity> LearnTrainSignAsync(long driverId, bool isLearnTrainSign);

        /// <summary>
        /// 获取所有已审批的司机列表
        /// </summary> 
        /// <param name="companyId">总公司/代理商Id</param> 
        /// <returns></returns>
        Task<IEnumerable<DriverEntity>> GetALLApprovedDriversAsync(long? companyId);
        /// <summary>
        /// 获取代理商司机列表
        /// </summary>
        /// <param name="agentRecordUuid">代理商Uuid</param>
        /// <param name="driverRoleType">司机角色类型</param>
        /// <returns></returns>
        Task<IEnumerable<DriverEntity>> GetListByAgentUuidAndDriverRoleType(string agentRecordUuid, DriverRoleType driverRoleType);

        /// <summary>
        /// 获取代理商司机动态信息
        /// </summary>
        /// <param name="agentRecordUuid">代理商Uuid</param>
        /// <returns></returns>
        Task<IEnumerable<DriverDynamicInfoEntity>> GetDriverDynamicInfo(string agentRecordUuid);

        /// <summary>
        /// 获取司机动态详情信息
        /// </summary>
        /// <param name="agentRecordUuid">代理商Uuid</param>
        /// <returns></returns>
        Task<IEnumerable<DriverDynamicDetailEntity>> GetDriverDynamicDetail(string agentRecordUuid);

        /// <summary>
        /// 获取司机/骑手实名认证待审核数量
        /// </summary>
        /// <param name="agentRecordUuid">代理商Uuid</param>
        /// <param name="roleType">司机角色类型</param>
        /// <param name="realNameVerifiesStatus">实名认证状态</param>
        /// <returns></returns>
        Task<int> GetRealNameVerifiesCount(string agentRecordUuid, DriverRoleType roleType, RealNameVerifiesStatus realNameVerifiesStatus);

        /// <summary>
        /// 获取司机/骑手车辆待审核数量
        /// </summary>
        /// <param name="agentRecordUuid">代理商Uuid</param>
        /// <param name="driver">司机角色类型</param>
        /// <param name="driverStatus">司机状态</param>
        /// <returns></returns>
        Task<int> GetVehiclePendingAuditCount(string agentRecordUuid, DriverRoleType roleType, DriverStatus driverStatus);
    }
}
